package game;

import java.awt.Color;

public class Button extends Field{
	private static final long serialVersionUID = 1L;
	private ActionPlatform platform;
	protected boolean pressed;
	protected boolean prevPress;
	
	public Button(Level l, int x, int y, int w, int h){
		super(l, x, y, w, h, Color.blue);
	}
	
	public void update(){
		super.update();
		if(pressed == false){
			prevPress = false;
		}
		pressed = false;
	}
	
	public void setActionPlatform(ActionPlatform p){
		platform = p;
	}
	
	public void calculateIntersectEffects(GameRectangle g){
		if(g instanceof Sprite){
			if(prevPress == false){
				if(platform != null){
					platform.activate();
				}
			}
			pressed = true;
			prevPress = true;
		}
	}
}
